package com.company.Sort;

import java.util.Arrays;

/**
 * @author VX5
 * @Title: MJC
 * @ProjectName interview
 * @Description: TODO
 * @date ${DAT}20:59
 */
public class quckSortPlus {
    public static void sort(int array[],int low,int high){
        int i = low;
        int j = high;
        int index = 0;
        int temp = 0;
        if (low >= high){
            return;
        }
        index = array[i];
        while (i < j){
            while (i < j && array[j] >= index){
                j--;
            }

            while (i < j && array[i] <= index){
                i++;
            }

            if (i < j){
                temp = array[i];
                array[i] = array[j];
                array[j] = temp;
            }
        }
        temp = array[low];
        array[low] = array[i];
        array[i] = temp;
        System.out.println(Arrays.toString(array));
        sort(array,low,j - 1);
        sort(array,j + 1, high);
    }

    public static void main(String[] args) {
        int[] arr = {25,84,21,47,15,27,68,35,20};
        sort(arr,0,arr.length - 1);
    }
}
